
package kaizone.haining.chaobohui.json;

import org.json.JSONObject;

public class WeatherDO {

    public static final String WEATHERINFO = "weatherinfo";

    public static final String CITY = "city";

    public static final String CITY_EN = "city_en";

    public static final String DATE_Y = "date_y";

    public static final String DATE = "date";

    public static final String WEEK = "week";

    public static final String FCHH = "fchh";

    public static final String CITYID = "cityid";

    //
    public static final String TEMP = "temp"; // temp

    public static final String temp1 = "temp1";

    public static final String temp2 = "temp2";

    public static final String temp3 = "temp3";

    public static final String temp4 = "temp4";

    public static final String temp5 = "temp5";

    public static final String temp6 = "temp6";

    //
    public static final String TEMPF = "tempF";// tempF

    public static final String tempF1 = "tempF1";

    public static final String tempF2 = "tempF2";

    public static final String tempF3 = "tempF3";

    public static final String tempF4 = "tempF4";

    public static final String tempF5 = "tempF5";

    public static final String tempF6 = "tempF6";

    //
    public static final String WEATHER = "weather";// weather

    public static final String weather1 = "weather1";

    public static final String weather2 = "weather2";

    public static final String weather3 = "weather3";

    public static final String weather4 = "weather4";

    public static final String weather5 = "weather5";

    public static final String weather6 = "weather6";

    //
    public static final String IMG = "img";// img

    public static final String img1 = "img1";

    public static final String img2 = "img2";

    public static final String img3 = "img3";

    public static final String img4 = "img4";

    public static final String img5 = "img5";

    public static final String img6 = "img6";

    public static final String img7 = "img7";

    public static final String img8 = "img8";

    public static final String img9 = "img9";

    public static final String img10 = "img10";

    public static final String img11 = "img11";

    public static final String img12 = "img12";

    public static final String IMG_SINGLE = "img_single";

    //
    public static final String IMG_TITLE = "img_title"; // img_title

    public static final String img_title1 = "img_title1";

    public static final String img_title2 = "img_title2";

    public static final String img_title3 = "img_title3";

    public static final String img_title4 = "img_title4";

    public static final String img_title5 = "img_title5";

    public static final String img_title6 = "img_title6";

    public static final String img_title7 = "img_title7";

    public static final String img_title8 = "img_title8";

    public static final String img_title9 = "img_title9";

    //
    public static final String WIND = "wind"; // wind

    public static final String wind1 = "wind1";

    public static final String wind2 = "wind2";

    public static final String wind3 = "wind3";

    public static final String wind4 = "wind4";

    public static final String wind5 = "wind5";

    public static final String wind6 = "wind6";

    //
    public static final String FL = "fl";

    public static final String fx1 = "fx1";

    public static final String fx2 = "fx2";

    public static final String fx3 = "fx3";

    public static final String fx4 = "fx4";

    public static final String fx5 = "fx5";

    public static final String fx6 = "fx6";

    public static final String INDEX = "index";

    public static final String INDEX_D = "index_d";

    public static final String INDEX48 = "index48";

    public static final String INDEX48_D = "index48_d";

    public static final String INDEX_UV = "index_uv";

    public static final String INDEX48_UV = "index48_uv";

    public static final String INDEX_XC = "index_xc";

    public static final String INDEX_TR = "index_tr";

    public static final String INDEX_CO = "index_co";

    //
    public static final String ST = "st";

    public static final String st1 = "st1";

    public static final String st2 = "st2";

    public static final String st3 = "st3";

    public static final String st4 = "st4";

    public static final String st5 = "st5";

    public static final String st6 = "st6";

    public static final String INDEX_CL = "index_cl";

    public static final String INDEX_LS = "index_ls";

    public static final String INDEX_AG = "index_ag";

    private WeatherInfo data;

    public WeatherInfo getData() {
        return data;
    }

    public void setData(WeatherInfo data) {
        this.data = data;
    }

    public static WeatherDO parseJson(String str) {
        WeatherDO weatherDO = new WeatherDO();
        try {
            JSONObject jsonObject = new JSONObject(str);

            JSONObject jsondate = jsonObject.getJSONObject(WEATHERINFO);
            WeatherInfo weatherInfo = WeatherInfo.parse(jsondate);
            weatherDO.setData(weatherInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return weatherDO;
    }

    public static class WeatherInfo {
        public String city;

        public String city_en;

        public String date_y;

        public String date;

        public String week;

        public String fchh;

        public String cityid;

        //
        public String[] temp; // temp

        //
        public String[] tempF;// tempF

        //
        public String[] weather;// weather

        //
        public String[] img;// img

        public String img_single;

        //
        public String img_title[]; // img_title

        //
        public String wind[]; // wind

        //
        public String fl[];

        public String index;

        public String index_d;

        public String index48;

        public String index48_d;

        public String index_uv;

        public String index48_uv;

        public String index_xc;

        public String index_tr;

        public String index_co;

        //
        public String st[];

        public String index_cl;

        public String index_ls;

        public String index_ag;

        public WeatherInfo() {
            temp = new String[6];
            tempF = new String[6];
            weather = new String[6];
            img = new String[12];
            img_title = new String[10];
            wind = new String[6];
            fl = new String[6];
            st = new String[6];
        }

        public static WeatherInfo parse(JSONObject jsonObject) {
            WeatherInfo weatherInfo = new WeatherInfo();
            try {
                weatherInfo.city = jsonObject.optString(CITY);
                weatherInfo.city_en = jsonObject.optString(CITY_EN);
                weatherInfo.date_y = jsonObject.optString(DATE_Y);
                weatherInfo.date = jsonObject.optString(DATE);
                weatherInfo.week = jsonObject.optString(WEEK);
                weatherInfo.fchh = jsonObject.optString(FCHH);
                weatherInfo.cityid = jsonObject.optString(CITYID);
                weatherInfo.index = jsonObject.optString(INDEX);
                weatherInfo.index_d = jsonObject.optString(INDEX_D);
                weatherInfo.index48 = jsonObject.optString(INDEX48);
                weatherInfo.index48_d = jsonObject.optString(INDEX48_D);
                weatherInfo.index48_uv = jsonObject.optString(INDEX48_UV);
                weatherInfo.index_uv = jsonObject.optString(INDEX_UV);
                weatherInfo.index_xc = jsonObject.optString(INDEX_XC);
                weatherInfo.index_tr = jsonObject.optString(INDEX_TR);
                weatherInfo.index_co = jsonObject.optString(INDEX_CO);
                weatherInfo.index_cl = jsonObject.optString(INDEX_CL);
                weatherInfo.index_ls = jsonObject.optString(INDEX_LS);
                weatherInfo.index_ag = jsonObject.optString(INDEX_AG);

                int tempLen = weatherInfo.temp.length;
                for (int i = 1; i <= tempLen; i++) {
                    weatherInfo.temp[i - 1] = jsonObject.optString(TEMP + i);
                }

                int tempFLen = weatherInfo.tempF.length;
                for (int i = 1; i <= tempFLen; i++) {
                    weatherInfo.tempF[i - 1] = jsonObject.optString(TEMPF + i);
                }

                int weatherLen = weatherInfo.weather.length;
                for (int i = 1; i <= weatherLen; i++) {
                    weatherInfo.weather[i - 1] = jsonObject.optString(WEATHER + i);
                }

                int imgLen = weatherInfo.img.length;
                for (int i = 1; i <= imgLen; i++) {
                    weatherInfo.img[i - 1] = jsonObject.optString(IMG + i);
                }

                int imgTitleLen = weatherInfo.img_title.length;
                for (int i = 1; i <= imgTitleLen; i++) {
                    weatherInfo.img_title[i - 1] = jsonObject.optString(IMG_TITLE + i);
                }

                int winLen = weatherInfo.wind.length;
                for (int i = 1; i < winLen; i++) {
                    weatherInfo.wind[i - 1] = jsonObject.optString(WIND + i);
                }

                int flLen = weatherInfo.fl.length;
                for (int i = 1; i < flLen; i++) {
                    weatherInfo.fl[i - 1] = jsonObject.optString(FL + i);
                }

                int stLen = weatherInfo.st.length;
                for (int i = 1; i < stLen; i++) {
                    weatherInfo.st[i - 1] = jsonObject.optString(ST + i);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }

            return weatherInfo;
        }

    }

}
